{% extends 'bms_home.html' %}


{% block content %}
    <h2 class="text-center">图书编辑</h2>

    <form action="" method="post">
        <p>书名:
            <input type="text" class="form-control" name="title" value="{{ edit_obj.title }}">
        </p>
        <p>价格:
            <input type="text" class="form-control" name="price" value="{{ edit_obj.price }}">
        </p>
        <p>出版日期:
            <input type="date" class="form-control" name="publish_time" value="{{ edit_obj.publish_time|date:'Y-m-d' }}">
        </p>
        <p>出版社:
{#            展示系统所有的出版社信息供用户选择一个#}
            <select name="publish_id" id="" class="form-control">
                {% for publish_obj in publish_queryset %}
                    {% if edit_obj.publish == publish_obj %}
                        <option value="{{ publish_obj.pk }}" selected>{{ publish_obj.title }}</option>
                    {% else %}
                        <option value="{{ publish_obj.pk }}">{{ publish_obj.title }}</option>
                    {% endif %}

                {% endfor %}
            </select>
        </p>
        <p>作者:
{#            展示系统所有的作者信息供用户选择一个#}
            <select name="author_list" id="" class="form-control" multiple>
                {% for author_obj in author_queryset %}
                    {% if author_obj in edit_obj.authors.all %}
                        <option value="{{ author_obj.pk }}" selected>{{ author_obj.name }}</option>
                        {% else %}
                        <option value="{{ author_obj.pk }}">{{ author_obj.name }}</option>
                    {% endif %}

                {% endfor %}
            </select>
        </p>
        <input type="submit" class="btn btn-warning btn-block" value="编辑">
    </form>

{% endblock %}


